//
//  FKTabBar.h
//  FKTabBarController
//
//  Created by 云眼科技 on 16/7/30.
//  Copyright © 2016年 CloudEyes. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN


#define FKBarDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead)


#pragma mark- ==============================> ENUM begin <============================

/**
 *  tabBar style, such as change the title color, or add a line view at the bottom of the item and so on.
 */
typedef NS_ENUM(NSInteger, FKTabBarStyle) {
    //change title color
    FKTabBarStyleNone,
    //add a line view at the bottom of the selected item.
    FKTabBarStyleLine = 0,
    //add a background view behind the selected item.
    FKTabBarStyleBackgrounView
} NS_ENUM_AVAILABLE_IOS(7_0);


/**
 *  set the item style, such as None, point or bage value.
 */
typedef NS_ENUM(NSInteger, FKTabBarItemStyle) {
    //none 
    FKTabBarItemStyleNone = 0,
    //add a red point at the right top corner of the item.
    FKTabBarItemStylePoint,
    //bageValue, used to show the message.
    FKTabBarItemStyleBageValue 
} NS_ENUM_AVAILABLE_IOS(7_0);


/**
 *  backgroundView style, such as change the title color, or add a line view at the bottom of the item and so on.
 */
typedef NS_ENUM(NSInteger, FKTabBarSelectedStyle) {
    //change title color
    FKTabBarSelectedStyleColorChange = 0,
    //add a line view at the bottom of the selected item.
    FKTabBarSelectedStyleTansformScale,
    //add a background view behind the selected item.
    FKTabBarSelectedStyleBackgroundView
} NS_ENUM_AVAILABLE_IOS(7_0);

/*
 *  item type .
 */
typedef NS_ENUM(NSInteger, FKTabBarItemType) {
    //point
    FKTabBarItemTypePoint = 0,
    //bageValue
    FKTabBarItemTypeBageValue
} NS_ENUM_AVAILABLE_IOS(7_0);

#pragma mark- ==============================> ENUM end <============================



#pragma mark- ==============================> backgroundView begin <============================

/**
 *  backgroun view type, there are two type 
 */
typedef NS_ENUM(NSInteger, FKBackgroundViewType) {
    //roundRect view and set it fill.
    FKBackgroundViewTypeRoundRectFill = 0,
    //roundRect view and set it stroke.
    FKBackgroundViewTypeRoundRectStroke 
} NS_ENUM_AVAILABLE_IOS(7_0);

NS_CLASS_AVAILABLE_IOS(7_0) @interface FKBackgroundView : UIView
@property (nonatomic, assign) FKBackgroundViewType type;
@property (nonatomic, strong, nullable) UIColor *fillColor;    //set the view background color
@property (nonatomic, strong, nullable) UIColor *strokeColor;  //set the view stroke line color
@end

#pragma mark- ==============================> backgroundView end <============================

@interface FKBageValueLabel : UILabel
@property (nonatomic, strong) UIColor *tintColor;
@property (nonatomic, assign) NSInteger bageValue;
@end


NS_CLASS_AVAILABLE_IOS(7_0) @interface FKTabBarItem : UIButton
@property (nonatomic, assign) FKTabBarItemType itemType;
@property (nonatomic, assign) NSInteger bageValue; //default is 0, if it is equal to 0, will hide the bageView
-(void)addIndicator;
-(void)removeIndicator;
@end



@protocol  FKTabBarDelegate;

NS_CLASS_AVAILABLE_IOS(7_0) @interface FKTabBar : UIView

/**
 *  delegate
 */
@property (nonatomic, weak) id <FKTabBarDelegate> delegate;
/**
 *  selected style for selected item.
 */
@property (nonatomic, assign) FKTabBarSelectedStyle selectStyle;
/**
 *  bar style
 */
@property (nonatomic, assign) FKTabBarStyle barStyle;
/**
 *  set whether animtaion when change the item.
 */
@property (nonatomic, assign) BOOL needAnimation;
/**
 *  set bar background color.
 */
@property (nonatomic, strong, nullable) UIColor *barTintColor;
/**
 *  if the indicator style is line, 
 */
@property (nonatomic, strong, nullable) UIColor *lineColor;
/**
 *  return the index of the selected item
 */
@property (nonatomic, assign) NSInteger selectedIndex;
/**
 *  return the current item which is being selected
 */
@property (nonatomic, strong, nullable) FKTabBarItem *selectedItem;
/**
 *  the items of the bar
 */
@property (nonatomic, strong, nullable) NSArray <NSString *> *titleArray;
/**
 *  backgroundView, defualt is nil.
 */
@property (nonatomic, strong, nullable) UIView *indicatorView;  
/**
 *  item width, default is screen width divide 5.
 */
@property (nonatomic, assign) CGFloat itemWidth;
/**
 *  the spacing of the two items.
 */
@property (nonatomic, assign) CGFloat itemSpacing;

/**
 *  change the item to target index.
 *
 *  @param index     target item index.
 *  @param animation need animation or not.
 */
-(void)moveToItemAtIndex:(NSInteger)index animation:(BOOL)animation;
/**
 *  if receive a new message. you you can call this method to add the bage Value or, add a red point to the item.
 *
 *  @param item  item.
 *  @param index item index
 */
-(void)addNewMessageToItem:(FKTabBarItem *)item atIndex:(NSInteger)index;

/**
 *  convenience init method, used to create the barView quickly.
 *
 *  @param frame     frame
 *  @param itemArray items array.
 *
 *  @return instance.
 */
-(instancetype)initWithFrame:(CGRect)frame titleArray:(nullable NSArray <NSString *> *)titleArray;

@end

@protocol FKTabBarDelegate <NSObject>

@optional
-(void)tabBar:(FKTabBar *)tabBar didSelectItem:(__kindof FKTabBarItem *)item;
-(void)tabBar:(FKTabBar *)tabBar didMoveToItem:(__kindof FKTabBarItem *)item FKBarDeprecated("not used yet");
-(void)tabBar:(FKTabBar *)tabBar didSelectItemAtIndex:(NSInteger)index;
-(void)tabBar:(FKTabBar *)tabBar didMoveToItemAtIndex:(NSInteger)index FKBarDeprecated("not used yet");
-(void)tabBar:(FKTabBar *)tabBar didReceiveNewMessageForItem:(__kindof FKTabBarItem *)item index:(NSInteger)index;


@end






NS_ASSUME_NONNULL_END